﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.LongER.Framework.Utils;
using Com.LongER.Business.ZDH003;
using Com.LongER.Business.ZDH003.ZDH003DSTableAdapters;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using Com.LongER.Framework.Utils.LogUtils;


namespace Com.LongER.Business.ZDH003
{
    public class CZDH003 : ABussinessBase
    {
        private Log log = Log.GetInstance();

        /// <summary>
        /// 获取车辆状态信息的值
        /// </summary>
        /// <returns></returns>
        public ZDH003DS.T_CHE_STADataTable GetT_CHE_STADetail(String strChepaiNum, String strJL_Date, String strJL_Time)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            T_CHE_STATableAdapter ta = new T_CHE_STATableAdapter(connectionString);

            ZDH003DS.T_CHE_STADataTable tb = ta.GetData(strChepaiNum, strJL_Date, strJL_Time);
            ta.Connection.Close();
            return tb;
        }

        /// <summary>
        /// 追加车辆状态信息的值
        /// </summary>
        /// <returns></returns>
        public Boolean InsertTCheSta(String strNewCHEPAI_NUM, String strNewJL_DATE, String strNewJL_TIME,
                                  String strNewYUNYING_STA, String strNewYUNSHU_STA,String strNewZHUANGZAI_STA,
                                  String strNewZHUANGZAI_LV,
                                  String strNewSUOZAI_SHENGSHI, String strNewSUOZAI_LUDUAN, String strNewDETAIL_LUDUAN,
                                  String strNewBEIZHU)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            T_CHE_STATableAdapter ta = new T_CHE_STATableAdapter(connectionString);

            int result = ta.IstTCheSta( strNewCHEPAI_NUM,  strNewJL_DATE,  strNewJL_TIME,
                                   strNewYUNYING_STA,  strNewYUNSHU_STA, strNewZHUANGZAI_STA,
                                   strNewZHUANGZAI_LV,
                                   strNewSUOZAI_SHENGSHI, strNewSUOZAI_LUDUAN, strNewDETAIL_LUDUAN,
                                   strNewBEIZHU);
            ta.Connection.Close();
            if (result > 0) return true;

            return false;
        }

        /// <summary>
        /// 更新车辆管理表
        /// </summary>
        /// <param name="strUserId"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public Boolean UpdateTCheSta(String strNewYUNYING_STA, String strNewYUNSHU_STA, String strNewZHUANGZAI_STA,
                                  String strNewZHUANGZAI_LV,
                                  String strNewSUOZAI_SHENGSHI, String strNewSUOZAI_LUDUAN, String strNewDETAIL_LUDUAN,
                                  String strNewBEIZHU,
                                  String strNewCHEPAI_NUM, String strNewJL_DATE, String strNewJL_TIME
                                  )
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            T_CHE_STATableAdapter ta = new T_CHE_STATableAdapter(connectionString);

            int result = ta.UpdTCheSta(strNewYUNYING_STA, strNewYUNSHU_STA, strNewZHUANGZAI_STA,
                                   strNewZHUANGZAI_LV,
                                   strNewSUOZAI_SHENGSHI, strNewSUOZAI_LUDUAN, strNewDETAIL_LUDUAN,
                                   strNewBEIZHU,
                                   strNewCHEPAI_NUM, strNewJL_DATE, strNewJL_TIME);
            ta.Connection.Close();

            if (result > 0) return true;

            return false;
        }

        /// <summary>
        /// 删除车辆状态信息
        /// </summary>
        /// <returns></returns>
        public Boolean DeleteTCheSta(String strChepaiNum, String strJL_DATE, String strJL_TIME)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            T_CHE_STATableAdapter ta = new T_CHE_STATableAdapter(connectionString);

            int result = ta.DltTCheSta(strChepaiNum, strJL_DATE, strJL_TIME);
            ta.Connection.Close();
            if (result > 0) return true;

            return false;
        }
    }
}
